package mvv.learn.spring.dao.elasticsearch;

import org.elasticsearch.client.Client;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;

/**
 * @author Manh Vu
 */
@Configuration
@EnableElasticsearchRepositories(basePackages = "org/springframework/data/elasticsearch/repositories")
public class ElasticsearchConfig {

	@Autowired
	private Client client;

	private ElasticsearchTemplate elasticsearchTemplate;

	@Bean
	public ElasticsearchOperations elasticsearchTemplate() {
		this.elasticsearchTemplate = new ElasticsearchTemplate(client);
		return this.elasticsearchTemplate;
	}

	protected Client getClient() {
		return client;
	}

	protected ElasticsearchTemplate getElasticsearchTemplate() {
		return elasticsearchTemplate;
	}
}
